package com.loc.newsapp.presentation.navgraph

import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.navigation
import androidx.navigation.compose.rememberNavController
import com.loc.newsapp.presentation.onboarding.OnBoardingScreen
import com.loc.newsapp.presentation.onboarding.OnBoardingViewModel

@Composable
fun NavGraph(startDestination: String) {
    val navController = rememberNavController()

    NavHost(
        navController = navController,
        startDestination = startDestination,
        builder = {
            navigation(
                route = Route.AppStartNavigation.route,
                startDestination = Route.OnBoardingScreen.route
            ) {
                composable(
                    route = Route.OnBoardingScreen.route
                ) {
                    val onBoardingViewModel: OnBoardingViewModel = hiltViewModel()
                    OnBoardingScreen(event = { onBoardingEvent ->
                        onBoardingViewModel.onEvent(onBoardingEvent)
                    })
                }
            }

            navigation(
                route = Route.NewsNavigation.route,
                startDestination = Route.NewsNavigationScreen.route
            ) {
                composable(route = Route.NewsNavigationScreen.route) {
                    Text("NewsNavigationScreen")
                }
            }
        }
    )
}